#!/usr/bin/env crystal
#  encoding: utf-8
# -*- coding: utf-8 -*-
# vim:set fileencoding=utf-8:

require "digest/md5.cr"
require "curl"


class Hash(K, V)
	def store(key : K, value : V) : Bool
		if has_key?(key)
			return false
		end
		upsert(key,value)
		return true
	end
end

class Digest::MD5
	def hex
  	return @digest.to_slice.hexstring
	end
end

class Crypto::MD5
	def self.hex_digest(data : String | Slice(UInt8)) : String
		context = Digest::MD5.new
		context.update data
		context.final
		return context.hex
	end
end

class Curl::Easy
	def self.new(uri : URI|String,headers : Hash(String,String)) : Curl::Easy
		tmp = new(uri)
		tmp.headers = headers
		return tmp
	end
end